package com.alibaba.citrus.cr.common.annotation;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import com.alibaba.lattice2.epoch.db.transaction.TransactionDefinition;
import com.alibaba.lattice2.epoch.db.transaction.Isolation;
import com.alibaba.lattice2.epoch.db.transaction.Propagation;

/**
 * @author zhangfei
 * @date 2021/12/20
 */
@Target({ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Inherited
@Documented
public @interface EpochTransactional {

    /**
     * 数据源appCode
     * @return
     */
    String appCode() default "";

    /**
     * 数据源code
     * @return
     */
    String dataSourceCode() default "";

    /**
     * 数据源类型，app或者tenant
     * @return
     */
    String dataSourceType() default "app";

    /**
     * 数据库类型，默认mysql
     * @return
     */
    String dbType() default "mysql";

    /**
     * 事务manager
     * @return
     */
    String transactionManager() default "";

    /**
     * 事务传播模式
     * @return
     */
    Propagation propagation() default Propagation.REQUIRED;

    /**
     * 事务隔离级别
     * @return
     */
    Isolation isolation() default Isolation.DEFAULT;

    /**
     * 超时时间
     * @return
     */
    int timeout() default TransactionDefinition.TIMEOUT_DEFAULT;

    /**
     * 是否是只读事务
     * @return
     */
    boolean readOnly() default false;
}
